package Basic9;

public class J16_OOP_Q72{

	public static void main(String[] args) {
		//상속, 인터페이스, 기본클래스를 이용해서 사각형 둘레 및 면적 계산하는 프로그램 작성
		
		J16_Rectangle r = new J16_Rectangle(12.0,24.5);
		System.out.println(r.toString());
		System.out.println(r.getArea());
		System.out.println(r.getCircum());
	}//메인

}//클래스





//인터페이스
interface Shape_Service{
	double getArea();
	double getCircum();
}



//클래스
class J16_Shape implements Shape_Service{
	private double width;
	private double height;
	
	public J16_Shape(){}
	
	public J16_Shape(double width, double height){
		this.width=width;
		this.height=height;
	}

	public double getWidth() {
		return width;
	}

	public void setWidth(double width) {
		this.width = width;
	}

	public double getHeight() {
		return height;
	}

	public void setHeight(double height) {
		this.height = height;
	}

	@Override
	public String toString() {
		return "J16_Shape [width=" + width + ", height=" + height + "]";
	}

	@Override
	public double getArea() {
		return 0;
	}

	@Override
	public double getCircum() {
		return 0;
	}

}






//사각형 클래스
class J16_Rectangle extends J16_Shape{
	
	public J16_Rectangle(double w, double h) {
		super(w,h);

		//객체 초기화 시 부모클래스 Shape의 생성자를 호출
	}
	
@Override
	public double getArea() {
		return getWidth()*getHeight();
	}	
	
@Override
	public double getCircum() {
		return getWidth()*2 + getHeight()*2;
	}

}


 
